import type { Dayjs } from 'dayjs';

import type { PageParam, PageResult } from '@vben/request';

import { requestClient } from '#/api/request';

export namespace InfraHolidayApi {
  /** 假期信息 */
  export interface Holiday {
    id: number; // 假期id
    holidayName?: string; // 假期名称
    holidayType?: number; // 假期类型：1-寒假 2-暑假 3-法定节假日 4-春假 5-秋假 6-其他
    startDate?: Dayjs | string; // 开始日期
    endDate?: Dayjs | string; // 结束日期
    remark: string; // 备注
    status?: number; // 有效状态
  }
}

/** 查询假期分页 */
export function getHolidayPage(
  data: PageParam,
  desensitize: boolean,
  encrypt: boolean,
) {
  return requestClient.post<PageResult<InfraHolidayApi.Holiday>>(
    '/infra/holiday/page',
    data,
    { desensitize, encrypt },
  );
}

/** 查询假期详情 */
export function getHoliday(id: number) {
  return requestClient.get<InfraHolidayApi.Holiday>(
    `/infra/holiday/get?id=${id}`,
  );
}

/** 新增假期 */
export function createHoliday(data: InfraHolidayApi.Holiday) {
  return requestClient.post('/infra/holiday/create', data);
}

/** 修改假期 */
export function updateHoliday(data: InfraHolidayApi.Holiday) {
  return requestClient.put('/infra/holiday/update', data);
}

/** 删除假期 */
export function deleteHoliday(id: number) {
  return requestClient.delete(`/infra/holiday/delete?id=${id}`);
}

/** 批量删除假期 */
export function deleteHolidayList(ids: number[]) {
  return requestClient.delete(
    `/infra/holiday/delete-list?ids=${ids.join(',')}`,
  );
}

/** 导出假期 */
export function exportHoliday(params: any) {
  return requestClient.download('/infra/holiday/export-excel', { params });
}
